package com.senthink.gl.business.security;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.senthink.gl.business.auth.AuthorityTreeDto;
import com.senthink.gl.business.common.exception.BusinessException;
import com.senthink.gl.business.domain.entity.User;
import com.senthink.gl.business.messages.CodeMsg;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

/**
 * CurrentUserService
 *
 * @author Ethan
 * @date 2017/11/14
 */
@Service
public class CurrentUserService {

    @Autowired
    private CodeMsg codeMsg;
    @Autowired
    private ObjectMapper objectMapper;

    private static final Logger LOGGER = LoggerFactory.getLogger(CurrentUserService.class);

    /**
     * 创建CurrentUser实例
     *
     * @param user {@link User}
     * @return {@link CurrentUser}实例
     */
    public CurrentUser convert(User user) {

        return new CurrentUser(user.getUid(),
                user.getName(),
                user.getMobile(),
                user.getAccount(),
                user.getPassword(),
                user.getLastPwdRestDate(),
                user.getRole(),
                user.isEnable());
    }
}
